from flask_marshmallow.sqla import SQLAlchemyAutoSchema
from marshmallow import fields
from apps.extensions import ma
from apps.modules.admin.models import Category

class CategorySchema(SQLAlchemyAutoSchema):
    class Meta:
        model = Category  # table = models.Album.__table__
        # include_relationships = True  # 输出模型对象时同时对外键，是否也一并进行处理
        include_fk = True  # 序列化阶段是否也一并返回主键
        # fields= ["id","name"] # 启动的字段列表
        # exclude = ["id","name"] # 排除字段列表


class CategoryOutSchema2(ma.Schema):  # 序列化类
    id = fields.Integer()
    title = fields.Str()
    parent_id = fields.Integer()
    alias = fields.Str()
    desc = fields.Str()
    count = fields.Integer()
    created_at = fields.DateTime()
    updated_at = fields.DateTime()